﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using JM.JCY.Common;
using JM.JCY.Proxy;
using JM.JCY.BusinessEntity;
using NCS.IConnect.ApplicationContexts;

namespace JM.JCY.SharePointComponent.PerformanceArchives.CreatePerformanceCase
{
    public partial class CreatePerformanceCaseUserControl : UserControl
    {
        public string _userName
        {
            set { ViewState["_userName"] = value; }
            get { return (string)ViewState["_userName"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (ApplicationContext.Current.UserName != null)
            {
                _userName = ApplicationContext.Current.UserName;
            }
            if (!IsPostBack)
            {
                //this.txtFiller.Text = _userName;

            }
        }

        protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
        {
            using (PerformanceCaseProxy proxy = new PerformanceCaseProxy())
            {
                var newDT = new PerformanceCaseDataSet.T_PerformanceCaseDataTable();
                var newRow = newDT.NewT_PerformanceCaseRow();

                newRow.Name = this.txtName.Text;
                newRow.FillYear = this.txtYear.Text;
                newRow.FillMonth = this.txtMonth.Text;

                newRow.Case_1 = this.txtCase1.Text;
                newRow.Case_2 = this.txtCase2.Text;
                newRow.Case_3 = this.txtCase3.Text;
                newRow.Case_4 = this.txtCase4.Text;
                newRow.Case_5 = this.txtCase5.Text;
                newRow.Case_6 = this.txtCase6.Text;
                newRow.Case_7 = this.txtCase7.Text;
                newRow.Case_8 = this.txtCase8.Text;
                newRow.Case_9 = this.txtCase9.Text;
                newRow.Case_10 = this.txtCase10.Text;
                newRow.Case_11 = this.txtCase11.Text;
                newRow.Case_12 = this.txtCase12.Text;
                newRow.Case_13 = this.txtCase13.Text;
                newRow.Case_14 = this.txtCase14.Text;
                newRow.Case_15 = this.txtCase15.Text;
                newRow.Case_16 = this.txtCase16.Text;
                newRow.Case_17 = this.txtCase17.Text;
                newRow.Case_18 = this.txtCase18.Text;
                newRow.Case_19 = this.txtCase19.Text;
                newRow.Case_20 = this.txtCase20.Text;
                newRow.Case_21 = this.txtCase21.Text;
                newRow.Case_22 = this.txtCase22.Text;
                newRow.Case_23 = this.txtCase23.Text;
                newRow.Case_24 = this.txtCase24.Text;
                newRow.Case_25 = this.txtCase25.Text;
                newRow.Case_26 = this.txtCase26.Text;
                newRow.Case_27 = this.txtCase27.Text;
                newRow.Case_28 = this.txtCase28.Text;

                newRow.Others = this.txtOthers.Text;
                newRow.Filler = this.txtFiller.Text;
                newRow.FillDate = this.dtFillDate.SelectedDate;
                newRow.Incharger = this.txtIncharger.Text;

                JCYUtility.UpdateCommonFields(newRow, "Iori");
                newDT.AddT_PerformanceCaseRow(newRow);
                proxy.UpdatePerformanceCase(newDT);

                Response.Redirect("PerformanceCase.aspx");

            }


        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("PerformanceCase.aspx");
        }
    }
}
